<?php 
header("content-type:text/html;charset=utf8");
$redis = new Redis();
$redis->connect('127.0.0.1','6379');
$pdo = new PDO("mysql:host=127.0.0.1;charset=utf8;dbname=peng",'root','root');
$user = $_POST['user'];
$pwd = $_POST['pwd'];
$code = $_POST['code'];
$tel = $_POST['tel'];
$recode = $redis->get('code'.$tel);
$time = date("Y-m-d H:i:s");
if ($recode) {
	if ($code == $recode) {
		$res = $pdo->exec("insert into user values('','$user','$pwd','$tel','$time')");
		if ($res) {
			$data = array('code'=>1,'msg'=>"注册成功");
		}
		else
		{
			$data = array('code'=>0,'msg'=>"注册失败");

		}
	}
	else
	{
			$data = array('code'=>3,'msg'=>"验证码有误");

	}
}
else
{
			$data = array('code'=>2,'msg'=>"验证码已过期");

}

echo json_encode($data);







 ?>